Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Calling methods from outside a class
You can access
PUBLICmethods from outside the class hierarchy of a given object by using an object reference to qualify the method name. When you invoke aPUBLICmethod on an object that is overridden in the object’s class hierarchy, Progress invokes the method in the bottom-most subclass that defines the method. There is no access toPRIVATEorPROTECTEDmethods from outside the class hierarchy.This is the syntax to invoke a method from outside a class instance:
Element descriptions for this syntax diagram follow:
return-varThe name of the variable to put the return value into.
object-referenceAn object reference for a class, a super class, or an interface that the class implements.
method-nameThe name of a
PUBLICmethod defined somewhere in the class hierarchy ofobject-reference.[parameter[ ,parameter] ... ]The parameters of the method. For more information on the syntax of
parameter, see the “Parameter passing syntax” reference entry in OpenEdge Development: Progress 4GL Reference .The compiler verifies that the parameters used in the method invocation are consistent with parameters defined for the method. The compiler verifies that the number, mode and data type of these parameters match exactly. There is no implicit conversion of any data types when passing method parameters. However, Progress does allow a dynamic temp-table or ProDataSet to be passed to static temp-table or ProDataSet parameter (respectively), and similarly for passing a static temp-table or ProDataSet to a corresponding dynamic temp-table or ProDataSet parameter.
Note: If the parameter is a class or interface type, the parameter is passed by value as an object reference. The effect of passing an object reference parameter is identical to assigning one object reference to another. For more information, see the "Defining an object reference as a parameter" section.The following example shows two sample classes, where a method in
acme.myObjs.CustObjcalls the publicAlert( )method in an instance ofacme.myObjs.Common.ErrorObjthat is created foracme.myObjs.CustObj:
In this case, the
rErrorobject reference is a private class variable that is initialized to an instance ofacme.myObjs.Common.ErrorObjreturned from theErrorHandler( )method of theacme.myObjs.Common.CommonObjsuper class. (See the listing for this super class in the "Calling methods from inside a class" section). Thisacme.myObjs.Common.ErrorObjinstance holds error information specifically for theacme.myObjs.CustObjclass that can be accessed using theAlert( )method implemented as follows:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |